<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/pages/inc/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>PTS专家工作台</title>
	<%@ include file="/pages/inc/header.jsp" %>
</head>

<body>
<%@ include file="/pages/inc/common.jsp" %>
<%@ include file="/pages/inc/menu.jsp" %>

<div class="pts-main">
	<%@ include file="/pages/inc/nav_opt.jsp" %>
	<div class="pts-page-title"><span>待处理服务</span></div>
	<div class="container-fluid">
		<div id="todo-services" class="pro-service-list"></div> 
	</div>
	<div class="pts-page-title"><span>已处理服务</span></div>
	<div class="container-fluid">
		<div id="done-services" class="pro-service-list"></div> 
	</div>
</div>
<%@ include file="/pages/inc/footer.jsp" %>

<script type="text/javascript">
	//====================================================================
	//定义模块类实例名（taskModule）、页面全局变量名（projectServiceVar）
	var projectServiceVar;
	
	//====================================================================
	
	//页面配置方法
	//author：robin
	//
	function initConfig(){
		//页面变量
		projectServiceVar = {
			//*******************************常量区******************************************//
			TASK_ZY:1,//属性说明1
			TASK_XS:"常量",//属性说明2
			//*******************************变量区******************************************//
			//serviceTaskList:eval("("+$("#host_serviceTaskList").val()+")")//当前任务列表 		
		};
	}

	function allocateProfessor(orderId){
		$.ajax({
			url: contextPath+"/opt/orderslist/allocatepro",
			type:"POST",
			data:{"orderId":orderId},
			cache:false,
			async:false,
			success: function(data, textStatus, jqXHR){
				if(data){
					//refresh page
					//initServiceOrders();
				}
			}
		});
	}

	function fmtOrderList(orders){
    	 var html="<table class='pts-table'>";
    	 html+="<tr> <th>编号</th> <th>服务采购订单</th> <th>所属项目</th> <th>采购时间</th> <th>计划时间</th> <th>订单状态 </th> <th>操作 </th> </tr>";
		 //循环输出订单信息 
		 var serviceOpt = "";
		 var rows = orders.rows;
   	     for(var i=0;i<rows.length;i++){
	   	   html+="<tr>";
	   	   html+="	<td>"+rows[i].id +"</td>";
	   	   html+="	<td>"+rows[i].serviceName +"</td>";
	   	   html+="	<td>"+rows[i].projectName +"</td>";
	   	   html+="	<td>"+rows[i].applyDate+" </td>";
	   	   html+="	<td>"+rows[i].exeBeginDate+"至"+rows[i].exeEndDate+"</td>";
	   	   html+="	<td>"+rows[i].status+"</td>";
	   	   if(rows[i].status=='0'){
	   			serviceOpt = "<a href='javascript:void(0)' onclick='allocateProfessor(\""+rows[i].id+"\")'>分配专家</a>";
		   }
	   	   html+="	<td>"+serviceOpt+"</td>";
	   	   html+="</tr>";
   	  	}
   	   	html+="</table>";
   	   	return html;
	}

	//初始化任务信息
	//author：JCJ
	function initServiceOrders() {
		$.ajax({
			url: contextPath+"/opt/orderslist/todo",
			type:"POST",
			data:{},
			cache:false,
			async:false,
			success: function(data, textStatus, jqXHR){
				if(data){
					$("#todo-services").html(fmtOrderList(data));
				}
			}
		});
		$.ajax({
			url: contextPath+"/opt/orderslist/done",
			type:"POST",
			data:{},
			cache:false,
			async:false,
			success: function(data, textStatus, jqXHR){
				if(data){
					$("#done-services").html(fmtOrderList(data));
				}
			}
		});
	}
	
	//====================================================================
	//主方法
	$(function() {
		initConfig();//初始化页面配置
		initServiceOrders();//初始化服务模块
	});
</script>
</body>
</html>
